home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 23 / AACD 23.iso / AACD / Utilities / BareED / rexx / Layout.rx < prev    next >
Text File  |  2001-01-25  |  3KB  |  88 lines

  1. /* Set layout to block format in an AmigaGuide compatible fashion with leading user's layout for 640 pixel wide screens
  2.  
  3.    25-Jan-01
  4.     Does not use quotes, double and so on as leading chars
  5.     Variable leftmost with righmost replaced (brain damaged?)
  6. */
  7.  
  8. BAREED_HOST = GetClip('BAREED')
  9.  
  10. IF BAREED_HOST = '' THEN DO
  11.     CALL SetClip('BAREED')    /* Remove from ClipNode */
  12.     EXIT 5
  13.     END
  14.  
  15. ADDRESS VALUE BAREED_HOST
  16.  
  17. CALL SetClip('BAREED')        /* Remove from ClipNode */
  18.  
  19. OPTIONS RESULTS
  20.  
  21. /* ------------------- MAIN ---------------- */
  22.  
  23. /* Layout is set here to 640 pixel per line (VGA) */
  24.  
  25. 'Set Error Off'            /* Turn off BareED's trap handling */
  26. 'Set Echo Off'            /* Turn off BareED's I/O reports */
  27.  
  28. rightmost = 640
  29.  
  30. rightmost = rightmost  - 4    /* Left window border has got 4 pixels */
  31. rightmost = rightmost - 18    /* Right window border has got 18 pixels */
  32. rightmost = rightmost - 2    /* BareED reserves 1 pixel in front and one pixel behind a text line */
  33. Get Charwidth ' '        /* Get width of a space in number of pixels */
  34. space = RESULT        /* We now have got the amount of space characters a line can contain */
  35. rightmost = rightmost - space    /* Due to uncoform AmigaGuide layout */
  36.  
  37. numchars = rightmost % space    /* Get amount of space characters that fit into a line */
  38.  
  39. Set Margin Right numchars    /* Set rightmost position */
  40.  
  41. Get Current Char        /* Try to get an ASCII character */
  42. currchar = RESULT
  43. textline = ''            /* An empty line! */
  44.  
  45. /* Fill up empty line with white spaces and other layout characteristics */
  46. DO WHILE C2D(currchar) < 33
  47.     textline = textline || currchar
  48.     Move Cursor Right
  49.     Get Current Char
  50.     currchar = RESULT
  51.     END
  52.  
  53. terminate = 0
  54. len = LENGTH( textline)        /* Length in number of characters */
  55. Get Cursor Y
  56. thisline = RESULT
  57.  
  58. /* Make the layout but care about a user's own made (for example a tab in front of a line) */
  59. DO WHILE terminate = 0
  60.     Layout Guide            /* Layout current line */
  61.     Move Cursor Down        /* Move cursor to next line */
  62.     Move Cursor Linestart    /* Move cursor to line start */
  63.     Get Cursor Y            /* Ask if the current line is the same as the last one */
  64.     IF RESULT == thisline THEN
  65.         BREAK            /* If so, quit */
  66.     thisline = RESULT        /* Else, remember */
  67.  
  68.     Get Current Line        /* Get contents of the existing line */
  69.     terminate = RC            /* Check for error */
  70.     IF terminate ~= 0 THEN    /* If error (linefeed or archive's end) then */
  71.         BREAK            /* break */
  72.  
  73.     /* Else drop user's line intro */
  74.     DO i = 1 TO len
  75.         c = SUBSTR( textline, i, 1)
  76.         Put Char c
  77.         END
  78.     END
  79.  
  80. EXIT
  81.  
  82. /* Demo line - point cursor to the first character of the "       This is a ...." and watch what BareED does .....
  83.                                           ^
  84.  
  85.        This is a very loooooong line used as a simple example for BareED's layout mechanism and the button interface (knob-bank)
  86. of BareED which can be used to use this script as an example.
  87.  
  88. demo line end */